<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>
        <ui:composition template="./../../Template/generalTemplate.xhtml">
            <ui:define name="content">
                <f:view beforePhase="#{bomManageManagedBean.iniView}">
                <h:form id="form" prependId="false"  >
                    
                        <p:panel header="BOM Management" style="height:495px;">
                            <div style="margin-top:20px;margin-left:50px;margin-right:50px;">
                                <p:growl id="growl" showDetail="true" />

                                <p:dataTable  id="addLine" value="#{bomManageManagedBean.bomLineItemList}" var="o" paginator="true" rows="6">
                                    <p:column >
                                        <f:facet name="header">Raw Material Name</f:facet>
                                        #{o.rawMaterial.rawMaterialName}
                                    </p:column>

                                    <p:column>
                                        <f:facet name="header" >Quantity</f:facet>
                                        #{o.quantity}
                                    </p:column>

                                    <p:column>
                                        <f:facet name="header">Action</f:facet>
                                        <h:commandLink value="Delete"  action="#{bomManageManagedBean.deleteLineItem(o)}"/>  

                                    </p:column>

                                </p:dataTable>
                                <br />
                                <p:commandButton value="Update" update="growl" actionListener="#{bomManageManagedBean.updateBOM}"/>
                                    
                               

                                <div style="position:absolute;top:450px;">

                                    <p:panel header="Add Item to BOM" toggleable="true">
                                        <table>
                                            <td><h:outputText value="Choose Raw Material "/></td>
                                            <td><h:selectOneMenu   id="studentlist" value="#{bomManageManagedBean.selectedRawMaterialName}">  
                                                    <f:selectItems value="#{bomManageManagedBean.getAllRawMaterialNames()}" />
                                          </h:selectOneMenu>  
                                            </td>

                                            <td><h:outputText value = "Quantity"/></td>
                                            <td><h:inputText     value="#{bomManageManagedBean.quantity}" required="true"  validatorMessage="Required quantity should be larger than 0">
                                                   
                                                </h:inputText>
                                            </td>

                                            <td><p:commandButton value="Add" actionListener="#{bomManageManagedBean.addLineItem}" update="addLine statusMessages" ajax="true"    >

                                                </p:commandButton></td>
                                        </table>
                                    </p:panel>
                                    <p:messages id="statusMessages"/>
                                </div>
                            </div>
                        </p:panel>
                   
                </h:form>
                     </f:view>
            </ui:define>
        </ui:composition>


    </body>
</html>
